<?php
session_save_path('sessions');
session_start();

include("include/dbUserTypes.php");

// Include our user class
include_once("include/user.php");

// Create a variable to store our user if we're validated
$user = null;

// Check if we're in a valid session. If not, go back to main login page.

if( !isset($_SESSION['user']) || $_SESSION['user'] == null ) {
    header("location:main_login.php");
}
else {
    // Unserialize our user to turn it back into a useful object
    $user = unserialize($_SESSION['user']);
}

// If we're not a business (or admin) go back to the user redirection page
if( $user->getUserType() != $USERTYPE_REGISTERED && $user->getUserType() != $USERTYPE_ADMIN)
    header("location:login_success.php");


// Include the header (CSS files, etc)
include("include/dbconnection.php");
include("include/header.php"); ?>


<body>
	<div id="wrapper">
		<div id="header"> </div>
		<div id="left">
			<div id="logo">
				<h1>Home Sale</h1>
				<p>Only By Owner</p>
			</div>
			<div id="nav">
				<ul>
					<li>
						<a href="addAhomeForSale.php">Add a House for sale</a>
					</li>
					<li>
						<a href="updateAhome.php">Update House information</a>
					</li>
					<li class="important">
						<a href="updateAhomePicture.php">Update House picture</a>
					</li>
            <li>
              <a href="searchhouse.php">Search House</a>
            </li>
					<li>
            <a href="emailMenu.php">Mailbox</a>
					</li>
					<li>
						<a href="logout.php">Logout</a>
					</li>
				</ul>
			</div>
			<div id="news">
        <?php include("adgeneratorleft1.php");?>
				<div class="hr-dots"> </div>
        <?php include("adgeneratorleft2.php");?>
				<p class="more">
					<a href="registered_index.php">more</a>
				</p>
			</div>
			<div id="support">
			</div>
		</div>
		<div id="right">
			<h2>Select a Property you want to modify</h2>
			<div id="welcome">



				<?php

		$currentUser = $user->getUserID();
		$var = 1;
		$homeIDquery = mysql_query("select * from list where userID = $currentUser");
		while($row = mysql_fetch_array($homeIDquery)){
			$homeID = $row[$TABLE_HOME_HOMEID];
			$houseQuery = mysql_query("select * from home where homeID = $homeID");

			while($row1 = mysql_fetch_array($houseQuery)){

				$address = $row1[$TABLE_HOME_ADDRESS];
				$streetName = $row1[$TABLE_HOME_STREETNAME];
				$city = $row1[$TABLE_HOME_CITY];
				$country = $row1[$TABLE_HOME_COUNTRY];

				?>

				<a href="mediaupload.php?homeID=
					<?php echo $homeID?>">Property <?php echo $var ?> listed
				</a>
				<br>
					<br>
						<?php echo $address." ".$streetName.", ".$city.", ".$country ?>
						<br>
							<br>
								<br>
									<br>


										<?php
				$var++;
				}
			}

		?>

									</div>
			<h3></h3>
			<div id="profile">
				<div id="corp">
					
          <?php include("adgeneratorbottomleft.php");?>
				</div>
				<div id="indu">
					
          <?php include("adgeneratorbottomright.php");?>
				</div>
				<div class="clear"> </div>
				<p class="more">
					<a href="registered_index">View Details</a>
				</p>
			</div>
		</div>
		<div class="clear"> </div>
		<div id="spacer"> </div>
		<div id="footer">
			<div id="copyright">
				&copy; Template taken from http://www.freewebsitetemplates.com/
			</div>
			<div id="footerline"></div>
		</div>

	</div>
</body>